import pymysql
class DictData:
    def __init__(self):
        self.kwargs={
            "host": "localhost",
            "port": 3306,
            "user":"root",
            "password":"123456",
            "database":"stu",
            "charset":"utf8"
        }
        self.db=pymysql.connect(**self.kwargs)
        self.cur = self.db.cursor()
    def closs(self):
        self.cur.close()
        self.db.close()
# try:
#     sql="update sanguo set defense=defense+1 where id=3;"
#     cur.execute(sql)
#     # cur.executemany(sql,[(),(),()]) 可以用many执行多次,传入参
#     # 数为列表,每次参数放在一个元组里
# except:
#     db.rollback()
# else:
#     db.commit()
# # 关闭数据库
